JavaScript

A5.u.array.seriesto Method

Syntax

A5.u.array.series.to(array[,settings])

Arguments

arrayarray

The array of object to convert to series.

settingsobject

The settings for the conversion.

namesobject

A mapping to convert the property names from each object in the array into the series name in the returned object. The name of the property in this object will be converted to a series with the name of the value specified.

blankobject

A mapping for missing values in the series. The name of the property in this object will be blank value used in the matching series.

missingstring

What to do with missing series that were referenced in the "names" setting but are missing from all objects in the passed in array. Options are "include" (the default) or "exclude".

extrastring

What to do with extra series that were not referenced in the "names" setting. Options are "include" (the default) or "exclude".

objectobject

The resulting series. Each series will be a property inside this object.

Description

Convert an array of objects into an object of series arrays.

Discussion

The A5.u.array.series.to method takes an array of object and converts them to a object with series arrays.

Example

var arr = [
	{firstName: 'Bob', lastName: 'Thomas', married: false},
	{firstName: 'Fred', lastName: 'Mills', age: 45},
	{lastName: 'Baker', age: 23, married: false}
]
var sObj = A5.u.array.series.to(arr,{
	names: {firstName: 'fn', lastName: 'ln', age: 'age'},
	blank: {firstName: '[none]', lastName: '[none]', age: '[unknown]'},
	extra: 'exclude'
});
// sObj = {
//	"fn": ["Bob","Fred","[none]"],
//	"ln": ["Thomas","Mills","Baker"],
//	"age": ["[unknown]",45,23]
// }